﻿using FairyGUI;
using System;
using System.Collections.Generic;
using System.Linq;

public class HeroInfo1Panel : BasePopupPanel
{
    private byte szPos;

    public override void Init()
    {
        base.Init();

        frame = view.GetChild("n1").asCom;
    }

    public override void Show(params object[] para)
    {
        this.szPos = (byte)para[0];

        this.SetInfo();

        base.Show(para);
    }

    public override void Close()
    {
        base.Close();
    }

    protected override GComponent CreateView()
    {
        return UIPackage.CreateObject("Main", "panel_more1").asCom;
    }

    private void SetInfo()
    {
        Attribute attribute = GameNetwork.Player.FighAttributeMgr.Get(szPos);

        GTextField tfDEX = frame.GetChild("n3").asTextField;
        tfDEX.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.DEX)))).FlushVars();

        GTextField tfSkillUp = frame.GetChild("n6").asTextField;
        tfSkillUp.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.SkillUp)))).FlushVars();

        GTextField tfAMP = frame.GetChild("n5").asTextField;
        tfAMP.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.AMP)))).FlushVars();

        GTextField tfCRT = frame.GetChild("n4").asTextField;
        tfCRT.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.CRT)))).FlushVars();

        GTextField tfSkillRes = frame.GetChild("n7").asTextField;
        tfSkillRes.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.SkillRes)))).FlushVars();

        GTextField tfEnergy = frame.GetChild("n11").asTextField;
        tfEnergy.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.Energy)))).FlushVars();

        GTextField tfEVD = frame.GetChild("n8").asTextField;
        tfEVD.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.EVD)))).FlushVars();

        GTextField tfDamageRes = frame.GetChild("n10").asTextField;
        tfDamageRes.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.DamageRes)))).FlushVars();

        GTextField tfKBL = frame.GetChild("n9").asTextField;
        tfKBL.SetVar("v", string.Format("{0}", CommonUtil.GetRate(attribute.Get(AttributeType.KBL)))).FlushVars();
    }
}
